<!-- 搜索表单 -->
<template>
    <el-card shadow="never" >
      <el-form
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="search"
        @submit.native.prevent
      >
        <el-row :gutter="24">
          <el-col :lg="5" :md="24">
            <el-form-item label="客户名称:" label-width="80px">
              <el-select v-model="where.customerId" clearable placeholder="请选择客户名称">
                <el-option v-for="(item, index) in customerDatas" :key="index" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="24">
            <el-form-item label="币种:" label-width="50px">
              <el-select v-model="where.currencyId" clearable placeholder="请选择币种">
                <el-option v-for="(item, index) in currencyDatas" :key="index" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="24">
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="search"
              >
                查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    </template>
    
    <script>
      const DEFAULT_WHERE = {
        keyword: '',  //关键字
        customerId:'',
        currencyId:'',
      };
      import { QueryCustomerPageList } from '@/api/basicdatamanager/customer';
      import { QueryAllChildDictViewByCode } from '@/api/systemmanager/dictmanager';
      export default {
        name: 'RecaccountSearch',
       
        data() {
          return {
            // 表单数据
            where: { ...DEFAULT_WHERE },
            customerDatas:[],
            currencyDatas:[],
          };
        },
        //初始化数据
        created(){
         this.queryStatusEnums();
        },
        methods: {
    
          /* 搜索 */
          search() {
            let params = {
              pageindex: 1,
              conditions: {},
              orderBys: [{ sort: "createDate", order: 1, }],
            };
    
            //供应商查询
            if(this.where.customerId){
              params.conditions.customerId = this.where.customerId;
            }

            //币种查询
            if(this.where.currencyId){
              params.conditions.currencyId = this.where.currencyId;
            }
    
            this.$emit('search', params);
          },

          /*  重置 */
          reset() {
            this.where = { ...DEFAULT_WHERE };
            this.search();
          },
    
          /* 系统状态 */
          async queryStatusEnums(){

            QueryAllChildDictViewByCode(this.Constant.C_HB).then((data)=>{
              this.currencyDatas = [];
              this.currencyDatas = data;
            });


            let params = {
              pageindex: 1,
              pagesize: 100000,
              conditions: [],
              orderBys: [{ sort: "createDate", order: 1, }],
            };

            params.conditions.push({
              key:"deleted",
              operator: 0,
              value: 0,
            });

            let result = await QueryCustomerPageList(params);
            this.customerDatas=[];
            this.customerDatas = result.items;

          },
        }
      };
    </script>
    